1. Field of the Invention
The present invention relates to the implementation of linear quantization for use in digital audio encoder and decoder applications.
2. Description of the Related Art
When coding an analogue signal to a digital representation, the values of the analogue signal which can be encoded are restricted to a number of values or quantized steps. For efficient digital encoding, the number of bits representing the audio samples will vary in number. The number of bits per audio sample are stored in a table, being quantization per subband.
MPEG1 (Layer 2) uses four such quantization tables, only one table is used depending on the sampling frequency and bitrate. Each table has sixteen columns and contains data for each of the thirty two subbands. The memory required to store the uncompressed data is 2048xc3x972 bytes.
There are several methods of compressing the four quantization tables, one method is to compress each table""s row of data. Repeated rows are not encoded. Also, if other quantization tables comprise the same row information as one previously compressed, then this table need not be encoded. In this manner, the four quantization tables used in MPEG1 (Layer 2) can be compressed into two tables. However, to recreate the original tables, an additional four tables are required. These comprise thirty two values used to point to the start location of the row data stored in one of the two previously compressed tables. This compression method requires memory space for 776xc3x972 bytes.
There are several problems to be solved. The need for better quality digital audio has prompted the increase of quantization levels and thus quantization tables. When designing an audio decoder in LSI using a RISC based processor, the cost of the chip increases with an increase in size. A major factor contributing to the chip size is the amount of memory used. When implementing a software method of decompression, the processing load increases.
The object of this invention is to provide an efficient method of compression requiring minimal decompression time.
Each of the quantization per subband tables are compressed into tables containing a number of parts. Each of the parts being the compressed format of one column. The parts consist of three pairs of data. The first data value of the pair define the subband up to which the nbits value remains the same, hereinafter referred to as a subband marker. For the first pair, the nbits remains constant for all subbands from zero to the subband marker. Second and third subband markers refer to the range from that of the previous subband marker to that of the current subband marker. If the current subband number is less than or equal to the subband marker, then the nbits is equal to the second value of the pair. Each pair of data are examined until the nbits has been found or, all three pairs have been searched. If the nbits is not found, nbits is by default equal to zero.
The subband marker of the third pair need not be equal to the last subband. For all subbands greater than the value of the subband marker in the last pair the nbits is equal to zero.
In the case of MPEG1 (layer 2) audio decoder, the invention eliminates memory wastage by encoding each of the original quantization per subband tables each into one part containing three pairs of data. For subbands up to and including the first value of the pair, the number of bits representing the audio sample (nbits) is equal to the second value of the pair. The second pair is decoded such that, for subbands greater than that of the first subband marker up to and including the second subband marker, the nbits is equal to the second value of the second part. Similarly for the third part, all subbands greater than the second subband marker up to and including the third subband marker, the nbits is equal to the second value of the third pair. Each pair is tested until the quantization has been determined. Should the nbits remain unresolved after examining the third pair, the nbits is equal to zero.
The quantization data is decoded for each of the subbands using sb as the counter. The appropriate part being indexed by multiplying the bit allocation data by six. The quantization data for all subbands are stored in the _nbits.
Encoding operation is as follows:
After identifying the nominal number of bits required to store an audio sample, If the samples are similar in amplitude, then grouping may be implemented. If so, this is signified by setting bit five of nbits high. After identifying nbits, the quantized sample is applied to a linear formula.
As stated in ISO/IEC 11172-3:1993(E), the subband sample is quantized by applying the value to the following linear formula:
Q=AX+B
X, being the subband sample divided by the scale factor.
The constants A and B are read from a table, quantization coefficients. A and B are indexed by nbits. If nbit equals three, then nbits is equal to zero. Should nbits be greater than sixteen, the indexing value is equal to the least significant two bits of nbits. Otherwise, the indexing value is equal to nbits. After generating the 25 index value, the A and B values are read and the linear formula is executed.
Decoding operation is as follows.
After storing all quantization data, the quantized audio samples can be read from the bit stream. The number of bits to be read for each quantized audio sample is equal to nbits, nbits being read from _nbits indexed by sb from zero to thirty one. The number of bits to be read is equal to the value of the least significant four bits of nbits. Should the number of bits read from the memory be greater than sixteen, then the quantized audio sample must be degrouped to three quantized audio samples. The quantized audio samples for each subband are stored in memory.
As stated in ISO/IEC 11172-3 1993(E), the quantized audio samples are dequantized by means of a linear formula:
S[sb]=Cxc3x97(D+qspl[sb])
The constants C and D are read from a table, classes of quantization. C and D are indexed by nbits for subband sb. If nbit is equal to three, than nbits is equal to zero. Should nbits be greater than sixteen, the indexing value is equal to the least significant two bits of nbits. Otherwise, the indexing value is equal to nbits. After generating the index value, the C and D values are read and the linear formula is executed.
A first aspect of the invention is a method to compress tables of linear quantization data used to digitally represent analog signals, each table comprising the structure of:
a number of columns being coded into groups of data;
the number of the columns is dependent on the accuracy of the coding and frequency bandwidth of the original signal, hereafter known as allocation;
length of the columns being equal to the number of sub divisions used to split the audio frequency band, hereafter known as subbands; and
three pairs of data for means of compressing each of the columns.
A second aspect of the invention is a method of compressing the columns according to the first aspect, comprising of the following steps:
comparing the subband to the first value of the pair hereafter known as subband marker;
when the subband is less than the subband marker, the number of bits used to quantize the sample is equal to the second value of the pair, hereafter being known as nbits;
repeating the comparison of the three pairs is done until the nbits has been found; and
following the comparison of all three pairs, the value of the nbits may not be resolved in such a situation, nbits is equal to zero.
A third aspect of the invention is a method implementing the compressed quantization tables according to first and second aspects, for the encoding process comprising the steps of:
selecting the compressed quantization per subband table;
selecting a suitable allocation value for each sample;
multiplying the allocation data value by six to index the compressed quantization table, the indexed value being nbits;
comparing the noise incurred by coding the analogue sample using the nbits to that of the acceptable noise level generated from the psychoacoustic model; and
repeating the selection process of the allocation to acquire the least number of the nbits needed to represent the analogue sample at the optimum acceptable noise level.
A fourth aspect of the invention is a method using the allocation to read the nbits from the compressed quantization tables in accordance to first and second aspects, comprising the steps of:
reading the allocation for each and every subband;
storing the allocation to memory hereafter known as alc;
using a counter, known hereafter as sb, to identify subband number;
selecting the compressed quantization per subband table;
reading the allocation, being the alc memory indexed by the sb;
calculating pointer to the compressed quantization per subband table using the allocation multiplied by six;
comparing data being indexed by the pointer to the compressed quantization per subband table with the sb (being the subband marker);
should the sb be less than or equal to the subband marker, the nbits representing the analogue sample, is equal to a value being indexed by the pointer plus one to the compressed quantization per subband table;
comparing the sb to all three of the parts until the nbits has been found;
if, after comparing all three of the parts, the nbits has not been found, the nbits is equal to zero;
the nbits is stored to memory, hereafter being known as _nbits, being indexed by the sb;
the nbits are decoded for all subbands;
reading quantized sample data from the bitstream, hereafter known as qspl, the number of bits representing the qspl being equal to the nbits read from the _nbits being indexed by the sb; and
reading of said qspl is repeated for all of the subbands.
A fifth aspect of the invention is a method to quantize/requantize samples comprising application of the samples to a linear formula, comprising the steps of:
reading the nbits for the current subband from _nbits being indexed by the sb;
decoding the nbits, hereafter to be known as linear_ptr;
reading linear constants being indexed by linear_ptr; and
applying the linear constants and sample to the linear formula.